<script setup lang="ts">
import SearchIcon from './assets/tools/search.svg'
import MapIcon from './assets/tools/map.svg'
import FlowIcon from './assets/tools/flow.svg'
import PicIcon from './assets/tools/pic.svg'
import LocationIcon from './assets/tools/location.svg'
import { inject, ref } from 'vue'

// 状态
const mapShow = ref(false)

// 工具列表
const tools = [
  {
    icon: SearchIcon,
    name: 'search',
  },
  {
    icon: PicIcon,
    name: 'pic',
  },
  {
    icon: FlowIcon,
    name: 'flow',
  },
  {
    icon: LocationIcon,
    name: 'location',
  },
  {
    icon: MapIcon,
    name: 'map',
  },
]
const handleClick = (name: string) => {
  switch (name) {
    case 'map':
      mapShow.value = !mapShow.value
      break;
  
    default:
      break;
  }
}

const { rightOpen } = inject('c-aside') as any
</script>

<template>
  <div :class="{tools: true, 'tools-close': rightOpen}">
    <div class="tools-btn">
      <img v-for="tool in tools" :src="tool.icon" :alt="tool.name" @click="handleClick(tool.name)" />
    </div>
    <div :class="{
      'tools-map': true,
      'tools-map-active': mapShow,
    }">
      <div class="tools-map-btn tools-map-btn-active"></div>
      <div class="tools-map-btn"></div>
      <div class="tools-map-btn"></div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.tools {
  position: fixed;
  bottom: 70px;
  right: 458px;
  z-index: 25;
  transition: all 0.3s ease-in-out;

  &-close {
    right: 70px;
  }

  &-btn {
    position: relative;
    z-index: 30;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;

    img {
      width: 32px;
      height: 32px;
      margin-top: 12px;
    }
  }

  &-map {
    position: absolute;
    bottom: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-left: -8px;
    border-radius: 2px;
    background: rgba(11, 48, 124, 0.4);
    backdrop-filter: blur(2.29px);
    opacity: 0;
    transform: translateX(-100%);
    transition: all 0.3s ease-in-out;

    &-active {
      opacity: 1;
    }

    &-btn {
      width: 98px;
      height: 68px;
      border-radius: 2px;
      border: 1px solid #1497FA;
      box-shadow: 0px 2.29px 5.71px 0px rgba(25, 136, 255, 0.3);
      margin-left: 8px;
      background-position: center center;
      background-size: cover;
      background-repeat: no-repeat;
      cursor: pointer;

      &:nth-child(1) {
        margin-left: 0;
        background-image: url('./assets/tools/pic1.png');
      }
      &:nth-child(2) {
        background-image: url('./assets/tools/pic2.png');
      }
      &:nth-child(3) {
        background-image: url('./assets/tools/pic3.png');
      }

      &-active {
        &:nth-child(1) {
          background-image: url('./assets/tools/pic1-select.png');
        }
        &:nth-child(2) {
          background-image: url('./assets/tools/pic2-select.png');
        }
        &:nth-child(3) {
          background-image: url('./assets/tools/pic3-select.png');
        }
      }
    }
  }
}
</style>
